//package com.fecean.aabbc.netty.handler4;
//
//import com.fecean.aabbc.netty.message4.MessageResponse;
//import com.fecean.aabbc.netty.message4.ResponseFuture;
//import io.netty.channel.ChannelHandler;
//import io.netty.channel.ChannelHandlerContext;
//import io.netty.channel.SimpleChannelInboundHandler;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.stereotype.Component;
//
//import java.util.Map;
//import java.util.concurrent.ConcurrentHashMap;
//
///**
// * NettyResponseChannelHandler
// *
// * @author: chenfenghai
// * @version: 1.0
// * @date: 2020-03-05 15:59
// * @blame Team
// */
//@Slf4j
//@Component
//@ChannelHandler.Sharable
//public class NettyResponseChannelHandler extends SimpleChannelInboundHandler<MessageResponse> {
//
//    private static final Map<String, ResponseFuture> RESPONSE_FUTURE_MAP = new ConcurrentHashMap<>();
//
//    public void addResponseFuture(String id, ResponseFuture responseFuture){
//        RESPONSE_FUTURE_MAP.putIfAbsent(id, responseFuture);
//    }
//
//    @Override
//    protected void channelRead0(ChannelHandlerContext ctx, MessageResponse messageResponse) throws Exception {
//        log.info("客户端[{}-{}]收到响应：{}",
//                messageResponse.getTenantId(), messageResponse.getCinemaCode(), messageResponse);
//
//        if(RESPONSE_FUTURE_MAP.containsKey(messageResponse.getId())){
//            RESPONSE_FUTURE_MAP.get(messageResponse.getId()).setResponse(messageResponse);
//            RESPONSE_FUTURE_MAP.remove(messageResponse.getId());
//        }
//    }
//}
